import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author: TanJingyu
 * @create: 2021-06-08 15:21
 **/
public class ProxyTestTwo {

    public static void main(String[] args) {
        ProxySon proxy = new ProxySon(new ProxyInvocationHandler());
        System.out.println(proxy.hashCode());
    }

    private static class ProxySon extends Proxy {

        /**
         * Constructs a new {@code Proxy} instance from a subclass
         * (typically, a dynamic proxy class) with the specified value
         * for its invocation handler.
         *
         * @param h the invocation handler for this proxy instance
         * @throws NullPointerException if the given invocation handler, {@code h},
         *                              is {@code null}.
         */
        protected ProxySon(InvocationHandler h) {
            super(h);
        }
    }

    private static class ProxyInvocationHandler implements InvocationHandler {

        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            System.out.println("调用了");
            return "null";
        }
    }
}
